package org.wyz.spark;

import java.io.Serializable;

public class Point implements Serializable {
    private double x;
    private double y;

    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

    double distance(Point p) {
        return Math.sqrt(Math.pow(x - p.getX(), 2) + Math.pow(y - p.getY(), 2));
    }

    Point sum(Point p) {
        return new Point(x + p.getX(), y + p.getY());
    }

    Point mean(int n) {
        return new Point(x / n, y / n);
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    @Override
    public String toString() {
        return x+","+y;
    }
}
